package k1_exercise;

import java.util.Arrays;
import java.util.Scanner;

public class Array_split {

    /**
     * v={1,2,3,4,5,6} => v1={1,2,3}  v2={4,5,6}
     */
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要拆分的数组长度：");
        int length = scanner.nextInt();

        int[] nums = {1,2,3,4,5,6};

        //根据控制台输入的长度值，创建两个待拆分的数组
        int[] nums_a = new int[length];
        int[] nums_b = new int[nums.length-length];

        for (int i = 0; i < nums.length ; i++) {
            if(i<nums_a.length){
                nums_a[i] = nums[i];
            }else{
                nums_b[i-nums_a.length] = nums[i];
            }
        }

        System.out.println(Arrays.toString(nums_a));
        System.out.println(Arrays.toString(nums_b));
    }

}
